package sample.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import fri.entiry.FrCurrency;
import fri.businessLayer.CurrencyBeanRemote;

public class ApplyController extends HttpServlet {

    @EJB
    private CurrencyBeanRemote currencyBeanRemote;
    
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            String action = request.getParameter("action");
            if (action == null) {
                if (action.equals("apply")) {
                    String txtValues        = request.getParameter("value");
                    String txtCurrencyId    = request.getParameter("selectVal");
                    String txtPaymentCode   = request.getParameter("code");
                }
            }
            
            request.setAttribute("lstCurrency", currencyBeanRemote.getAllCurrency());
            RequestDispatcher rd = request.getRequestDispatcher("reqApply.jsp");
            rd.forward(request, response);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }
}
